﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using BookClubIt.Processor;

namespace BookClubIt
{
    public class BaseUserControl : UserControl
    {
        public int CID
        {
            get
            {
                int cid = 0;
                if (Request.QueryString["id"] != null)
                    int.TryParse(Request.QueryString["id"], out cid);
                return cid;
            }
        }
        public int CurrentUserId
        {
            get
            {

                string username = HttpContext.Current.User.Identity.Name;
                DTO.Member member = MemberProcessorInstance.GetMemberByUsername(username);
                return member.Id;
            }
        }
        AmazonProcessor amazonProcessor;
        public AmazonProcessor AmazonProcessorInstance
        {
            get
            {
                if (amazonProcessor == null) amazonProcessor = new AmazonProcessor();
                return amazonProcessor;
            }
        }

        BookProcessor bookProcessor;
        public BookProcessor BookProcessorInstance
        {
            get
            {
                if (bookProcessor == null) bookProcessor = new BookProcessor();
                return bookProcessor;
            }
        }

        BookClubProcessor bookClubProcessor;
        public BookClubProcessor BookClubProcessorInstance
        {
            get
            {
                if (bookClubProcessor == null) bookClubProcessor = new BookClubProcessor();
                return bookClubProcessor;
            }
        }
        MemberProcessor memberProcessor;
        public MemberProcessor MemberProcessorInstance
        {
            get
            {
                if (memberProcessor == null) memberProcessor = new MemberProcessor();
                return memberProcessor;
            }
        }
        EmailProcessor emailProcessor;
        public EmailProcessor EmailProcessorInstance
        {
            get
            {
                if (emailProcessor == null) emailProcessor = new EmailProcessor();
                return emailProcessor;
            }
        }
    }
}